from django.conf.urls import url
from . import views
from rest_framework_jwt.views import obtain_jwt_token

urlpatterns = [
    #/users/usernames/(?P<username>\w{5,20})/count/
    url(r'^usernames/(?P<username>\w{5,20})/count/$',views.RegisterUsernameCountAPIView.as_view(),name='usernamecount'),
    url(r'^phones/(?P<mobile>1[345789]\d{9})/count/$',views.RegisterPhoneCountAPIView.as_view(),name='phonecount'),
    url(r'^$', views.RegisterCreateView.as_view(),name='registercreate'),
    # JWT的登录认证
    url(r'^auths/$',views.UserAuthorizationView.as_view(),name='auths'),
    # 个人中心
    url(r'^infos/$',views.UserCenterInfoAPIView.as_view(),name='detail'),
    url(r'^emails/$',views.EmailUpdateView.as_view(),name='email'),
    url(r'^emails/verification/$',views.VerificationEmailView.as_view(),name='VerificationEmail'),
    url(r'^browerhistories/$',views.UserBrowsingHistoryView.as_view(),name='history'),
    # url(r'(?P<pk>\d+)/password/$',views.UpdatePasswdView.as_view(),name='password'),
    url(r'^image_codes/(?P<image_code_id>.+)/$', views.FindPasswordView.as_view()),

    # GET /users/accounts/aaaaa/sms/token/?text
    url(r'^accounts/(?P<account>.{5,20})/sms/token', views.VerifyAccountExist.as_view()),

    # GET /sms_codes/?access_token=eyJle
    url(r'^sms_codes/$', views.GetSmsCode.as_view()),

    # GET /accounts/aaaaa/password/token/?sms_code=084054
    url(r'accounts/(?P<account>.{5,20})/password/token/', views.VerifySmsCode.as_view()),

    # SetNewPassword  "POST /users/10/password/
    url(r'^(?P<user_id>\d+)/password1/$', views.NewPassword.as_view()),
    url(r'^(?P<use_id>\d+)/password/$',views.UserCenterPassAPIView.as_view()),
]

from .views import AddressViewSet
from rest_framework.routers import DefaultRouter
router = DefaultRouter()
router.register(r'addresses', AddressViewSet, base_name='address')
urlpatterns += router.urls


# 注册完成之后实现自动登录
# 注册完成之后还
# 什么是自动登录()